/**
 * File Comment: Ita a GUI
 */
package edu.gatech.oad.project.presentation;
//$codepro.audit.disable
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * This class is a panel that allows the user
 * to interact with the GUI by providing a
 * home screen.
 * 
 * @author Group 17
 * @version 1
 */
public class NurseHome extends JPanel {
  
  /**
   * Field driver: holds the Driver connected to the GUI
   */
  private Driver driver;
  
  /**
   * Field lblNurseHome: label
   */
  public JLabel lblNurseHome;
  
  /**
   * Field btnViewedit: view/edit patients button 
   */
  public JButton btnViewedit;
  
  /**
   * Field btnAppsByDoctor: view appointments by doctor button
   */
  public JButton btnAppsByDoctor;
  
  /**
   * Field btnAppsByDate: view appointments by date button
   */
  public JButton btnAppsByDate;
  
  /**
   * Field btnLogOut: log out button
   */
  public JButton btnLogOut;

 /**
  * Constructor.
  * 
  * @param driver the Driver connected to the GUI
  */
 public NurseHome(Driver driver) {
   this.driver = driver;
  GridBagLayout gridBagLayout = new GridBagLayout();
  gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
  gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
  gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
  setLayout(gridBagLayout);
  
  lblNurseHome = new JLabel("Nurse Home");
  lblNurseHome.setFont(new Font("Lucida Grande", Font.PLAIN, 30));
  GridBagConstraints gbc_lblNurseHome = new GridBagConstraints();
  gbc_lblNurseHome.insets = new Insets(0, 0, 5, 0);
  gbc_lblNurseHome.gridx = 4;
  gbc_lblNurseHome.gridy = 1;
  add(lblNurseHome, gbc_lblNurseHome);
  
  btnViewedit = new JButton("View/Edit Patients");
  btnViewedit.addActionListener(new ButtonListener1(this));
  GridBagConstraints gbc_btnViewedit = new GridBagConstraints();
  gbc_btnViewedit.insets = new Insets(0, 0, 5, 0);
  gbc_btnViewedit.gridx = 4;
  gbc_btnViewedit.gridy = 3;
  add(btnViewedit, gbc_btnViewedit);
  
  btnAppsByDoctor = new JButton("Appointments by Doctor");
  btnAppsByDoctor.addActionListener(new ButtonListener2(this));
  GridBagConstraints gbc_btnAppsByDoctor = new GridBagConstraints();
  gbc_btnAppsByDoctor.insets = new Insets(0, 0, 5, 0);
  gbc_btnAppsByDoctor.gridx = 4;
  gbc_btnAppsByDoctor.gridy = 4;
  add(btnAppsByDoctor, gbc_btnAppsByDoctor);
  
  btnAppsByDate = new JButton("Appointments for the Day\n");
  btnAppsByDate.addActionListener(new ButtonListener3(this));
  GridBagConstraints gbc_btnAppsByDate = new GridBagConstraints();
  gbc_btnAppsByDate.insets = new Insets(0, 0, 5, 0);
  gbc_btnAppsByDate.gridx = 4;
  gbc_btnAppsByDate.gridy = 5;
  add(btnAppsByDate, gbc_btnAppsByDate);
  
  btnLogOut = new JButton("Log Out");
  btnLogOut.addActionListener(new ButtonListener4(this));
  GridBagConstraints gbc_btnLogOut = new GridBagConstraints();
  gbc_btnLogOut.gridx = 4;
  gbc_btnLogOut.gridy = 6;
  add(btnLogOut, gbc_btnLogOut);
 } // end constructor method
  
 /**
  * Get the Driver.
  * 
  * @return the Driver connected to the GUI
  */
  public Driver getDriver()
 {
   return this.driver;
 } // end getDriver method

  /**
   * This private inner class implements ActionListener for btnViewedit.
  * 
  * @author Group 17
  * @version 1
   */
 private class ButtonListener1 implements ActionListener
 {
   /**
    * Field home: the NurseHome being used
    */
   private NurseHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the NurseHome being used
    */
   private ButtonListener1(NurseHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new NursePatientList(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener1 class
 
 /**
  * This private inner class implements ActionListener for btnAppsByDoctor.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener2 implements ActionListener
 {
   /**
    * Field home: the NurseHome being used
    */
   private NurseHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the NurseHome being used
    */
   private ButtonListener2(NurseHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new NurseAppByDoctor(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener2 class
 
 /**
  * This private inner class implements ActionListener for btnAppsByDate.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener3 implements ActionListener
 {
   /**
    * Field home: the NurseHome being used
    */
   private NurseHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the NurseHome being used
    */
   private ButtonListener3(NurseHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new NurseAppByDate(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener3 class
 
 /**
  * This private inner class implements ActionListener for btnLogOut.
  * 
  * @author Group 17
  * @version 1
  */
 private class ButtonListener4 implements ActionListener
 {
   /**
    * Field home: the NurseHome being used
    */
   private NurseHome home;
   
   /**
    * Field driver: holds the Driver connected to the GUI
    */
   private Driver driver;
   
   /**
    * Constructor.
    * 
    * @param home the NurseHome being used
    */
   private ButtonListener4(NurseHome home)
   {
     this.home = home;
     this.driver = home.getDriver();
   } // end constructor method
   
   /**
    * Default method for ActionListener.
    * 
    * @param e the ActionEvent triggering the ActionListener
    */
   public void actionPerformed(ActionEvent e)
   {
     this.driver.getFrame().setContentPane(new LogIn(this.driver));
     this.driver.getFrame().pack();
   } // end actionPerformed method
 } // end ButtonListener4 class
} // end NurseHome class